<template>
	<view class="page-content">
		<f-navbar title="公告" navbarType="1"></f-navbar>
		<!-- <view class="tab-block">
			<u-tabs :list="tabList" :current="tabIndex" lineColor="#138E57" lineWidth="160rpx" lineHeight="5rpx"
				:scrollable="false" :inactiveStyle="{color:'#000000',fontSize:'32rpx',fontWeight:'bold'}"
				:activeStyle="{color:'#000000',fontSize:'32rpx',fontWeight:'bold'}" :itemStyle="{height:'98rpx'}"
				@click="changeTab"></u-tabs>
		</view> -->
		<view class="page-content-main">
			<scrollList :list="list" :loadComplete="loadComplete" @pullUpLoad="pullUpLoad" ref="scrollList">
				<view class="message-list">
					<!-- <view v-for="(item,index) in 5" :key="index">
						<view class="item-time">2023-02-11</view> -->
						<view v-for="(childItem,childIndex) in list" :key="childIndex" class="item-info"  @click="goLink(`/pages/common/details?id=${childItem.noticeId}&detailsType=1&memo=${childItem.isRead}&param=${enCodeUrl(childItem)}`)">
							<view class="title">
								{{childItem.noticeTitle}} 
								<u-badge absolute :isDot="true"  :show="childItem.isRead == '0'" type="error" :offset="['14rpx', '-30rpx']"></u-badge>
							</view>
							<view class="content text-cut text-cut2">
								{{childItem.createTime}}
							</view>
						</view>
					<!-- </view> -->
				</view>
			</scrollList>
		</view>
	</view>
</template>

<script>
	import {
		messageList,
		getNoticeList
	} from "@/api/common.js"
	export default {
		data() {
			return {
				tabIndex: 0,
				// 消息类型：0任务消息，1报警消息，2系统通知
				tabList: [
					{
						name: '任务信息',
						// badge: {
						// 	value: 5,
						// },
					}, 
					{
						name: '报警消息',
					}, 
					{
						name: '系统通知',
					},
				],
				listParams: {
					pageNum: 1,
					pageSize: 10,
				},
				list: [],
				loadComplete: true,
				
				list:[],
				status_load: 'more',
				// memo 1已读  0未读
				queryParams:{
					recipientId:'',
					pageNum: 1,
					pageSize: 10,
					type:0,
				},
			};
		},
		onShow() {
			this.$store.dispatch("actionGetUserInfo")
			this.queryParams.pageNum = 1;
			this.getList()
		
		},
		methods: {
			changeTab(e) {
				this.tabIndex = e.index
				this.queryParams.type = e.index
				this.queryParams.pageNum == 1
				this.getList()
			},
			getList() {
				this.queryParams.recipientId = this.userInfo.userId
				getNoticeList(this.queryParams).then((res) => {
					this.$refs.scrollList.pullUpDone(!1)
					if (this.queryParams.pageNum == 1) {
						this.list = res.data.records
						this.loadComplete = !0
					} else {
						if (this.list.length == res.data.total) {
							this.$refs.scrollList.pullUpDone(!0)
						} else {
							this.list = [...this.list, ...res.data.records]
						}
					}
				})
			},
			pullUpLoad() {
				this.queryParams.pageNum++;
				this.getList();
			},
			
		},
	};
</script>

<style lang="scss" scoped>
	.page-content {
		height: 100vh;
		display: flex;
		flex-direction: column;

		/deep/.u-badge {
			&.u-badge--error {
				background-color: #DF0E0E;
			}
		}

		.tab-block {
			background: #ffffff;
			border-bottom: 2rpx solid #EFEFEF;

			/deep/.u-tabs__wrapper__nav__line {
				bottom: 0;
			}
		}

		.list-count-header {
			height: 84rpx;
			margin-top: 1rpx;
			padding: 20rpx 24rpx;
			background: #ffffff;

			.screen-icon {
				width: 44rpx;
				height: 44rpx;
				margin-left: 24rpx;
			}
		}

		&-main {
			position: relative;
			flex: 1;
			overflow: hidden;

			.message-list {
				padding: 0 32rpx;

				.item-time {
					margin-top: 36rpx;
					text-align: center;
				}

				.item-info {
					margin-top: 30rpx;
					padding: 32rpx;
					background: #fff;
					border-radius: 12rpx;

					.title {
						font-size: 32rpx;
						color: #000000;
						margin-bottom: 10rpx;
						position: relative;
						display: inline-block;
						font-weight: bold;
					}

					.content {
						color: #666668;
					}
				}
			}
		}
	}
</style>